function uploadFile() {
    const fileInput = document.getElementById('fileInput');
    const file = fileInput.files[0];
    if (!file) {
        alert('Please select a file to upload.');
        return;
    }
    const formData = new FormData();
    formData.append('file', file);
    fetch('http://localhost:5000/upload', { // 更新这里的 URL 为 Flask 应用的端口
        method: 'POST',
        body: formData
    })
    .then(response => {
        if (!response.ok) {
            throw new Error('Network response was not ok');
        }
        return response.json();
    })
    .then(data => {
        console.log(data);
        alert('File uploaded successfully');
    })
    .catch(error => {
        console.error('Error:', error);
    });
}